from alembic.command import current


class ListNode(object):
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next


class Solution(object):
    def isPalindrome(self, head):
        """
        :type head: Optional[ListNode]
        :rtype: bool
        """
        vals = []
        current = head
        while current:
            vals.append(current.val)
            current = current.next

        return vals == vals[::-1]


aa = [1,2,2,1]
a = ListNode(1)
b = ListNode(2)
c = ListNode(2, b)
d = ListNode(1, c)

# a.next = b
# b.next = c
# c.next = d

s = Solution()
print(s.isPalindrome(a))